#include "scriptviewer.h"

#include "HighLightTextViewer.h"
#include "ScriptActionCreator.h"


/************************************************/
/* CScriptViewer                                */
/*  constructor                                 */
/************************************************/
ScriptViewer::ScriptViewer(HighLightTextViewer & textViewer, ScriptActionCreator &actionCreator,
                           QObject *parent) :
   IF_ScriptViewerInterface(parent),
   m_textViewer(textViewer),
   m_actionHtmlMaker(actionCreator)
{
   connect( &m_textViewer, SIGNAL(textChanged()), this, SIGNAL(textChanged()) );
}

/**
 * set as active the block following the current one.
 */
void ScriptViewer::onActivateNextBlock()
{
   m_textViewer.onActivateNextBlock();
}

int ScriptViewer::getActiveBlockLength() const
{
   return m_textViewer.getActiveBlockLength();
}

void ScriptViewer::getScriptContent(QString &content) const
{
   m_textViewer.getScriptContent( content);
}

void ScriptViewer::setScriptContent(const QString &content)
{
   m_textViewer.setScriptContent( content);
}

void ScriptViewer::setEditMode(bool edit)
{
   m_textViewer.setEditMode( edit);
}

void ScriptViewer::addLightEvent()
{
   m_textViewer.insertHtml( m_actionHtmlMaker.makeHtmlForLightAction() );
}

void ScriptViewer::setMenuActionList(const QList<QAction *> &actionList)
{
   m_textViewer.addActions( actionList);
}

void ScriptViewer::addMediaEvent()
{
   m_textViewer.insertHtml( m_actionHtmlMaker.makeHtmlForMediaAction() );
}

void ScriptViewer::addSearchPath(const QString &path)
{
   m_textViewer.setSearchPaths( m_textViewer.searchPaths()<<path );
}
